package main

import "fmt"

func main() {
	//1、定义int类型
	//var num int = 10
	//num = 22.22
	//fmt.Printf("num=%v 类型：%T", num, num)

	//2、int8的范围演示
	//var num int8 = 88
	//fmt.Printf("num=%v 类型：%T", num, num)

	//(-128 到 127)
	//var num int8 = 130 //./main.go:16:6: constant 130 overflows int8
	//fmt.Printf("num=%v 类型：%T", num, num)

	//var num int16 = 130 //ok
	//fmt.Printf("num=%v 类型：%T", num, num)

	//unsafe.Sizeof	查看不同长度的类型，在内存里面的存储空间

	//var a int32 = 15
	//fmt.Printf("a=%v 类型：%T \n", a, a)
	//fmt.Println(unsafe.Sizeof(a)) //4个字节

	//3、uint8范围（0-255）
	//var n1 uint8 = 200
	//fmt.Printf("n1=%v 类型：%T", n1, n1)

	//4、

	//5、int不同长度直接的转换
	//var a1 int32 = 10
	//var a2 int64 = 21
	//fmt.Println(int64(a1) + a2) //把a1转换成int64
	//fmt.Println(a1 + int32(a2)) //把a2转换成int32

	//高位向低位转换的时候要注意
	//var n1 int16 = 130
	//fmt.Println(int8(n1)) //-126 有问题了
	//
	//var n2 int16 = 110
	//fmt.Println(int8(n2)) //110
	//fmt.Println(int64(n2)) //110

	//6、数字字面量语法
	//num := 30
	//fmt.Printf("num=%v ,类型为%T \n", num, num)
	//fmt.Println(unsafe.Sizeof(num)) //表示64位的计算机，int就是int64 占用8个字节

	num := 9
	fmt.Printf("num=%v\n", num) //原样输出
	fmt.Printf("num=%d\n", num) //十进制输出
	fmt.Printf("num=%b\n", num) //二进制输出
	fmt.Printf("num=%o\n", num) //八进制输出
	fmt.Printf("num=%x\n", num) //十六进制输出
}
